
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<div class="row" style="padding:2px">
	<div class="col-sm-12 col-md-12 col-lg-12">
		<div class="form-group">
			<a id="ajax_proStart_btn_add" class="btn btn-default" <s:property value="isCreate('prostart')"/> data-toggle="modal"><i class="fa fa-lg fa-plus"></i> 新建项目立项</a>
		</div>
	</div>
</div>
<!-- rows -->
<!-- widget grid -->
<section id="widget-grid" class="">
	<!-- row -->
	<div class="row">
		<input id="keyId" name="keyId" hidden value="<s:property value="keyId"></s:property> "/>
		<!-- NEW WIDGET START -->
		<article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
			<!-- Widget ID (each widget will need unique ID)-->
			<div class="jarviswidget " role="widget" id="wid-id-0" data-widget-editbutton="false"
				data-widget-colorbutton="false" 
				data-widget-togglebutton="false" 
				data-widget-deletebutton="false" 
				data-widget-fullscreenbutton="false"
				data-widget-custombutton="false" 
				data-widget-sortable="false">
                <header role="heading">
                    <ul id="myTab1" class="nav nav-tabs pull-left in">
                        <li class="active">
                            <a href="#s1" data-toggle="tab"><i class="fa fa-fw fa-lg fa-credit-card"></i> 项目立项信息  【流转中】   </a>
                        </li>
                        <li>
                            <a href="#s2" id="finish" data-toggle="tab"><i class="fa fa-fw fa-lg fa-users"></i> 项目立项信息  【已归档】 </a>
                        </li>

                    </ul>
                    <div class="widget-toolbar" role="menu">
                        <a  href="#" key="ajax_prostart_group_list"   class="btn btn-primary">
                            <i class="fa fa-fw fa-download"></i>导出项目立项
                        </a>
                    </div>
                    <span class="jarviswidget-loader"><i class="fa fa-refresh fa-spin"></i></span>
                </header>
				<%--<header>--%>
					<%--&lt;%&ndash;<span class="widget-icon"> <i class="fa fa-table"></i> </span>&ndash;%&gt;--%>
					<%--&lt;%&ndash;<h2>项目立项信息 </h2>&ndash;%&gt;--%>
				<%--</header>--%>
				<!-- widget div-->
				<div role="content">
					<!-- widget edit box -->
					<div class="jarviswidget-editbox">
						<!-- This area used as dropdown edit box -->

					</div>
					<!-- end widget edit box -->

					<!-- widget content -->
					<div class="widget-body ">

                        <div id="myTabContent1" class="tab-content  ">
                            <div class="tab-pane fade in active " id="s1" style="margin-left: 10px;">

                                <div>

                                    <div class="row" id="ajax_proStart_list_row">
                                        <table id="ajax_proStart_table" class="table table-striped table-bordered table-hover">
                                        </table>
                                        <div id="ajax_proStart_list_page">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane fade in " id="s2" style="margin: 10px">
                                <div >
                                    <div class="row" id="ajax_finish_list_row">

                                        <table id="ajax_finish_table" class="table table-striped table-bordered table-hover">
                                        </table>
                                        <div id="ajax_finish_list_page">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

					</div>
					<!-- end widget content -->
				</div>
				<!-- end widget div -->
			</div>
			<!-- end widget -->
		</article>
		<!-- WIDGET END -->

	</div>

	<!-- end row -->

	<!-- end row -->

</section>
<!-- end widget grid -->



<script type="text/javascript">
	// DO NOT REMOVE : GLOBAL FUNCTIONS!
	pageSetUp();

	function reload(){
		loadURL("ajax!prostart.action",$('#content'));
	}

</script>

<script type="text/javascript">
$(function(){
    load_proStart_jqGrid();
    load_finish_jqGrid();

});
function load_proStart_jqGrid(){
        jQuery("#ajax_proStart_table").jqGrid({
            	url:'ajax-prostart!list.action?keyId='+$("input#keyId").val(),
        	    datatype: "json",
            	colNames:['项目名称 ',"项目批复金额",'文档状态',"归档日期","操作","id","是否创建人"],
            	colModel:[
                    {name:'name',index:'name', width:30,sortable:false},
           		    {name:'replayMoney',index:'replayMoney', width:70},
           		    {name:'processState',index:'processState', width:120,sortable:false},
           		    {name:'endTime',index:'endTime', width:110,sortable:false},
					{name:'act',index:'act', width:150,sortable:false,fixed:true},
           		    {name:'id',index:'id', width:50,hidden:true},
					{name:'isCreateMan',index:'isCreateMan',width:50,hidden:true}
             	],
                rowNum : 10,
                rowList:[10,20,30],
                pager : '#ajax_proStart_list_page',
                sortname : 'id',
                sortorder : "asc",
                gridComplete:function(){
                    var ids=$("#ajax_proStart_table").jqGrid('getDataIDs');
                    for(var i=0;i<ids.length;i++){
                        var cl=ids[i];
						var rowData = $("#ajax_proStart_table").jqGrid("getRowData",cl);
						var state = rowData.processState;
						var isCreateMan = rowData.isCreateMan;
                        var de="<button class='btn btn-default' data-original-title='查看' onclick=\"fn_proStart_read('"+cl+"');\"><i class='fa fa-eye'></i>查看</button>"+" ";
						var dt="<button class='btn btn-default' data-original-title='查看' onclick=\"fn_proStart_destroy('"+cl+"');\"><i class='fa fa-eye'></i>废止</button>"+" ";
						if (state.indexOf("退回中") >= 0 && isCreateMan == "Y"){
							jQuery("#ajax_proStart_table").jqGrid('setRowData',ids[i],{act:de+dt});
						}
						else{
							jQuery("#ajax_proStart_table").jqGrid('setRowData',ids[i],{act:de});
						}

                    }

                    $(".ui-jqgrid-bdiv").css("overflow-x","hidden");
                    jqGridStyle();
                },
    	        jsonReader: {
    			    root: "dataRows",
    			    page: "page",
    			    total: "total",
    			    records: "records",
    			    repeatitems : false
    			},
    			multiselect : false,
                rownumbers:true,
                gridview:true,
                shrinkToFit:true,
                viewrecords: true,
                autowidth: true,
                height:'auto',
                forceFit:true,
                loadComplete: function() {
                }
            });
            $(window).on('resize.jqGrid', function() {
                jQuery("#ajax_proStart_table").jqGrid('setGridWidth', $("#ajax_proStart_list_row").width());
            })

            jQuery("#ajax_proStart_table").jqGrid('navGrid', "#ajax_proStart_list_page", {
                edit : false,
            	add : false,
            	del : false,
            	search:false
            });
	};
function load_finish_jqGrid(){
    jQuery("#ajax_finish_table").jqGrid({
        url:'ajax-prostart!listFinish.action?keyId='+$("input#keyId").val(),
        datatype: "json",
        colNames:['项目名称 ',"项目批复金额",'文档状态',"归档日期","操作","id","是否创建人"],
        colModel:[
            {name:'name',index:'name', width:30,sortable:false},
            {name:'replayMoney',index:'replayMoney', width:70},
            {name:'processState',index:'processState', width:120,sortable:false},
            {name:'endTime',index:'endTime', width:110,sortable:false},
            {name:'act',index:'act', width:150,sortable:false,fixed:true},
            {name:'id',index:'id', width:50,hidden:true},
            {name:'isCreateMan',index:'isCreateMan',width:50,hidden:true}
        ],
        rowNum : 10,
        rowList:[10,20,30],
        pager : '#ajax_finish_list_page',
        sortname : 'id',
        sortorder : "asc",
        gridComplete:function(){
            var ids=$("#ajax_finish_table").jqGrid('getDataIDs');
            for(var i=0;i<ids.length;i++){
                var cl=ids[i];
                var rowData = $("#ajax_proStart_table").jqGrid("getRowData",cl);
                var de="<button class='btn btn-default' data-original-title='查看' onclick=\"fn_proStart_read('"+cl+"');\"><i class='fa fa-eye'></i>查看</button>"+" ";
                jQuery("#ajax_finish_table").jqGrid('setRowData',ids[i],{act:de});

            }

            $(".ui-jqgrid-bdiv").css("overflow-x","hidden");
            jqGridStyle();
        },
        jsonReader: {
            root: "dataRows",
            page: "page",
            total: "total",
            records: "records",
            repeatitems : false
        },
        multiselect : false,
        rownumbers:true,
        gridview:true,
        shrinkToFit:true,
        viewrecords: true,
        autowidth: true,
        height:'auto',
        forceFit:true,
        loadComplete: function() {

        }
    });
    $(window).on('resize.jqGrid', function() {
        jQuery("#ajax_finish_table").jqGrid('setGridWidth', $("#ajax_finish_list_row").width());
    })

    jQuery("#ajax_finish_table").jqGrid('navGrid', "#ajax_finish_list_page", {
        edit : false,
        add : false,
        del : false,
        search:false
    });
};

	$("#ajax_proStart_btn_add").click(function(){
		loadURL("ajax-prostart!input.action",$('#content'));
	});

	function fn_proStart_read(id){
		loadURL("ajax-prostart!read.action?keyId="+id,$('#content'));
	}
	function fn_proStart_destroy(id){
		ajax_action("ajax-prostart!destroy.action",{keyId:id},null,function(pdata){
			_show(pdata);
			jQuery("#ajax_proStart_table").trigger("reloadGrid");
		})
	}
    $("#ajax_prostart_btn_all").unbind("click").bind("click",function(){
        $("input#keyId").val("");
        $("#ajax_prostart_table").jqGrid('setGridParam',{url:'ajax-prostart!list.action'}).trigger("reloadGrid");
    });
    $("a#finish").off("click").on("click",function(e){
        var width = $("#ajax_proStart_list_row").width();
        $("#ajax_finish_list_row").width(width);
        jQuery("#ajax_finish_table").jqGrid('setGridWidth', $("#ajax_finish_list_row").width());
        $(this).tab('show');
        return false;
    });
    $("a#export-prostart").off("click").on("click",function(){
        var actionUrl = "ajax-prostart!export.action";
        ajax_action(actionUrl,null,null,function(pdata){

        })
    });

        //弹出选择框
    $("a[key=ajax_prostart_group_list]").unbind("click").bind("click",function(){
        ajax_action("ajax-prostart!entityDlg.action",null,{},function(pdata){
            oDialog.open({
                title:"请选择你要导出的字段",
                data:pdata.data.data,
                callback:function(){
                    var obj =$("#group input:checked");
                    var name = getArrProp(obj,"key");
                    var id = getArrProp(obj,"id");
                    window.location.href="ajax-prostart!export.action?keyIds="+id+"&keyNames="+name;
                    _show({"state":"200","message":"导出成功！","title":"操作状态"});
                }
            });
        });
    });
</script>
